<div style="margin-top: 50px;"></div>
<form class="layui-form form" method="post" action="<?= base_url("word/type/save_button") ?>">

    <input type="hidden" name="id" class="id" value="<?= $row['id'] ?>">

    <div class="layui-form-item"><label class="layui-form-label">标签名称</label>
        <div class="layui-input-block" style="width: 350px;">
            <select name="test_biaoqian" class="test_biaoqian">
                <?php foreach ($select as $k => $v): ?>

                    <?php if ($row['biaoqian'] == $v['id']) : ?>
                        <option selected value="<?= $v['id'] ?>"><?= $v['name'] ?></option>
                    <?php else: ?>
                        <option value="<?= $v['id'] ?>"><?= $v['name'] ?></option>
                    <?php endif; ?>
                <?php endforeach; ?>
            </select>
        </div>
    </div>
    <div class="layui-form-item"><label class="layui-form-label">分类名称</label>
        <div class="layui-input-block" style="width: 350px;">
            <?php if(in_array($row['name'],['网春大拜年',"超级测测测","超级配配配"])){ ?>
            <input type="text" name="test_name" placeholder="请输入分类名称" class="layui-input test_name layui-disabled" value="<?= $row['test_name'] ?>"disabled>
            <?php }else{ ?>
                <input type="text" name="test_name" placeholder="请输入分类名称" class="layui-input test_name" value="<?= $row['test_name'] ?>">
            <?php } ?>
        </div>
    </div>

    <div class="layui-form-item"><label class="layui-form-label">上线状态</label>
        <div class="layui-input-block">
            <?php if ($row['online'] == 2): ?>
                <input type="radio" name="test_online" value="2" title="上线" checked>
                <input type="radio" name="test_online" value="1" title="下线">
            <?php else: ?>
                <input type="radio" name="test_online" value="2" title="上线">
                <input type="radio" name="test_online" value="1" title="下线" checked>
            <?php endif; ?>
        </div>
    </div>

    <div class="layui-form-item"><label class="layui-form-label">分类排序</label>
        <div class="layui-input-block" style="width: 350px;">
            <input type="text" name="test_sort" placeholder="请输入分类排序" class="layui-input test_sort"
                   value="<?php if($row['test_sort']==999999999){echo 0;}else{echo $row['test_sort'];} ?>">
        </div>
    </div>

    <div class="layui-form-item"><label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn" style="margin-left: 15px;" id="edit">保存</button>
        </div>
    </div>
</form>

<script>
    $("#edit").click(function () {
        var test_name = $('.test_name').val();
        var test_sort = $('.test_sort').val();
        var test_online = $("input[name='test_online']:checked").val();
        var test_biaoqian = $('.test_biaoqian option:selected').val();
        var id = $('.id').val();
        var data = {
            test_name: test_name,
            test_sort: test_sort,
            test_biaoqian: test_biaoqian,
            id: id,
            test_online: test_online
        };
        $.ajax({
            type: "post",
            data: data,
            dataType: "json",
            url: "<?=base_url("word/type/save_button")?>",
            success: function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {time: 1000}, function () {
                        window.location.reload()
                    })
                } else {
                    layer.msg(res.msg, {time: 2000})
                }
            }
        })
    })
</script>